package cn.fx.controller;

import cn.fx.domain.Store;
import cn.fx.feign.StoreFeignClient;
import cn.fx.util.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
@Api(value = "价格API",description="商品数量相关的CRUD功能")
public class OrderController {

    @Autowired
    private StoreFeignClient storeFeignClient;

    @PostMapping("/storeSave")
    @ApiOperation(value = "添加商品信息")
    public JsonResult storeSave(@RequestBody Store store){
        try {
            storeFeignClient.save(store);
            return JsonResult.me();
        } catch(Exception e) {
            e.printStackTrace();
            return JsonResult.me().setMsg("网络异常");
        }
    }
}